namespace SB2.Core;

public class ScriptWithSqlExecuteCommand : ScriptWithSql
{
    public override async Task<object> RunAsync(DynamicFunctionExcDto param)
    {
        if (param.Script == null) throw new Exception("sql无效脚本");
        var sql = param.Script.GetCode();
        var parameters = GetParameters(param.Param.Request);
        try
        {
            var dt = await _dbContext.Ado.ExecuteCommandAsync(sql, parameters);
            return dt;
        }
        catch (Exception e)
        {
            throw new Exception($"sql脚本内执行失败：{e.Message}");
        }
    }

}
